let gulp = require("gulp");
let {
    paths
} = require("./gulp.config");
let connect = require("gulp-connect");


function devStyles() {
    return gulp.src(paths.styles.src)
        .pipe(gulp.dest(paths.styles.dest))
        .pipe(connect.reload());
}

function devScripts() {
    return gulp.src(paths.scripts.src)
        .pipe(gulp.dest(paths.scripts.dest))
        .pipe(connect.reload());
}

function devHtml() {
    return gulp.src(paths.html.src)
        .pipe(gulp.dest(paths.html.dest))
        .pipe(connect.reload());
}

function myConnect() {
    return connect.server({
        root: "./src",
        port: 8888,
        livereload: true
    });
}

function watch() {
    gulp.watch(paths.styles.src, devStyles);
    gulp.watch(paths.scripts.src, devScripts);
    gulp.watch(paths.html.src, devHtml);
}

let dev = gulp.series(gulp.parallel(myConnect, watch));

module.exports = dev;